package jp.gr.java_conf.ryz.summarize.client.view;

import jp.gr.java_conf.ryz.summarize.library.Action;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SimplePanel;

public class ToolPanel extends FlowPanel
{
	private static final String DefaultStyleName = "toolPanel";
	
	
	public ToolPanel(Action exportAction
			, Action allSelectAction
			, Action clearSelectAction
			, Action allBoldAction
			, Action clearBoldAction)
	{
		super();
		
		init(exportAction, allSelectAction, clearSelectAction, allBoldAction, clearBoldAction);
	}
	
	
	private void init(final Action exportAction
			, final Action allSelectAction
			, final Action clearSelectAllAction
			, final Action allBoldAction
			, final Action clearAllBoldAction)
	{
		addStyleName(DefaultStyleName);
		
		add(new HTML("<hr />"));
		add(new HTML("<h3>基本操作</h3>"));
		
		Button exportButton = new Button("HTML生成");
		exportButton.addClickHandler(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				exportAction.invoke();
			}
		});
		add(new SimplePanel(exportButton));
		
		Button saveButton = new Button("保存");
		add(new SimplePanel(saveButton));
		
		add(new HTML("<hr />"));
		add(new HTML("<h3>一括操作</h3>"));
		
		Button allSelectButton = new Button("全て選択");
		allSelectButton.addClickHandler(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				allSelectAction.invoke();
			}
		});
		add(new SimplePanel(allSelectButton));
		
		Button clearSelectButton = new Button("全ての選択状態を解除");
		clearSelectButton.addClickHandler(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				clearSelectAllAction.invoke();
			}
		});
		add(new SimplePanel(clearSelectButton));
		
		Button allBoldButton = new Button("全て太文字");
		allBoldButton.addClickHandler(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				allBoldAction.invoke();
			}
		});
		add(new SimplePanel(allBoldButton));
		
		Button clearBoldButton = new Button("全て太文字を解除");
		clearBoldButton.addClickHandler(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				clearAllBoldAction.invoke();
			}
		});
		add(new SimplePanel(clearBoldButton));
		
		
		
	}
}
